package com.cnap.model.strategy.scale;

import com.cnap.db.entity.ScaleStrategyPO;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * 扩缩容策略
 *
 * @author xc
 **/
public class ScaleStrategyDTO {
    private String svcId;
    private CommonScaleDTO vm;
    private CommonScaleDTO container;
    private CommonScaleDTO cluster;

    /**
     * get
     *
     * @return SvcId
     */
    public String getSvcId() {
        return svcId;
    }

    /**
     * set
     *
     * @param svcId svcId
     */
    public void setSvcId(String svcId) {
        this.svcId = svcId;
    }

    /**
     * get
     *
     * @return Vm
     */
    public CommonScaleDTO getVm() {
        return vm;
    }

    /**
     * set
     *
     * @param vm vm
     */
    public void setVm(CommonScaleDTO vm) {
        this.vm = vm;
    }

    /**
     * get
     *
     * @return Container
     */
    public CommonScaleDTO getContainer() {
        return container;
    }

    /**
     * set
     *
     * @param container container
     */
    public void setContainer(CommonScaleDTO container) {
        this.container = container;
    }

    /**
     * get
     *
     * @return Cluster
     */
    public CommonScaleDTO getCluster() {
        return cluster;
    }

    /**
     * set
     *
     * @param cluster cluster
     */
    public void setCluster(CommonScaleDTO cluster) {
        this.cluster = cluster;
    }

    /**
     * 转换成po列表
     *
     * @return 结果
     */
    public List<ScaleStrategyPO> toPOs() {
        List<CommonScaleDTO> commonScaleDTOS = Arrays.asList(this.vm, this.container, this.cluster);
        return commonScaleDTOS.stream().filter(Objects::nonNull).map(CommonScaleDTO::toPO).collect(Collectors.toList());
    }

}
